package com.company.biz.user.service.impl;

import com.company.biz.user.service.SendMessageService;
import com.company.common.exception.BizException;
import com.company.common.util.SendMessageUtil;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@Service
public class SendMessageServiceImpl implements SendMessageService {
    @Resource
    private RedisTemplate<String, String> redisTemplate;

    @Override
    public Boolean sendEmail(String email) {
        String code6 = RandomStringUtils.randomNumeric(6);
        //写入redis缓存
        redisTemplate.opsForValue().set(email, code6, 5, TimeUnit.MINUTES);
        Boolean f = SendMessageUtil.SendEmail(email,code6);
        return f;
    }

}
